package life.majiang.community.service;

import life.majiang.community.mapper.TagMapper;
import life.majiang.community.model.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service
@Transactional(propagation = Propagation.REQUIRED,rollbackFor = Exception.class)
public class TagService {

    @Autowired
    private TagMapper tagMapper;

    @Transactional(propagation = Propagation.SUPPORTS,readOnly = true)
    public List<Tag> findAllTags(){
       return tagMapper.selectAllTags();
    }

    public void addTag(Tag tag){
        tagMapper.insertTag(tag);
    }

    public void modifyTag(Tag tag){
        tagMapper.updateTag(tag);
    }

}
